package com.Trainer.TrainerInterface;

import com.data.UpData;

import javax.swing.*;
import java.awt.*;

public class TrainerUpPanel extends JPanel {
    //属性
    protected JLabel totalLabel;
    JLabel correctLabel;
    JLabel wrongLabel;
    protected JLabel total;
    JLabel correct;
    JLabel wrong;
    JLabel currentPattern;

    //构造器
    public TrainerUpPanel(int x, int y, int weight, int height,UpData upData){
        totalLabel = new JLabel("已做题数:");
        correctLabel = new JLabel("正确数:");
        wrongLabel = new JLabel("错误数:");
        total = new JLabel(""+upData.getSum());
        correct = new JLabel(""+upData.getCorrect());
        wrong = new JLabel(""+upData.getWrong());
        currentPattern = new JLabel("请选择你的模式！");

        //布局
        setLayout(null);
        setBounds(x,y,weight,height);
        //标签修饰
        setTable(totalLabel,0,height-30,90,30,20);
        setTable(total,90,height-30,40,30,20);
        setTable(correctLabel,140,height-30,80,30,20);
        setTable(correct,220,height-30,40,30,20);
        setTable(wrongLabel,270,height-30,80,30,20);
        setTable(wrong,350,height-30,40,30,20);
        setTable(currentPattern,500,10,350,90,32);

        //加入标签
        add(totalLabel);
        add(total);
        add(correctLabel);
        add(correct);
        add(wrongLabel);
        add(wrong);
        add(currentPattern);
    }

    //方法

    public JLabel getTotal() {
        return total;
    }

    public void setTotal(JLabel total) {
        this.total = total;
    }

    public JLabel getCorrect() {
        return correct;
    }

    public void setCorrect(JLabel correct) {
        this.correct = correct;
    }

    public JLabel getWrong() {
        return wrong;
    }

    public void setWrong(JLabel wrong) {
        this.wrong = wrong;
    }

    public JLabel getCurrentPattern() {
        return currentPattern;
    }

    public void setCurrentPattern(String currentPattern) {
        this.currentPattern.setText(currentPattern);
    }

    public JLabel getWrongLabel() {
        return wrongLabel;
    }

    public JLabel getCorrectLabel() {
        return correctLabel;
    }

    //设置标签样式
    public void setTable(JLabel label,int x,int y,int weight,int height,int size){
        label.setBounds(x,y,weight,height);
        label.setOpaque(true);
        label.setFont(new Font("微软雅黑",Font.PLAIN,size));
        label.setHorizontalAlignment(SwingConstants.CENTER);
    }
}
